package cn.wj.school.server.dubbo;

import cn.wj.school.cloud.dubbo.JteachDubboService;
import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ReferenceConfig;
import com.alibaba.dubbo.config.RegistryConfig;

/**
 * @Author: yueding
 * @Description:
 * @Date: Created in 16:35 2019/1/14
 * @Modified By: yueding Copyright(c) cai-inc.com
 */
public class DubboService {

    private static JteachDubboService dubboService;
    private static ApplicationConfig application;
    private static RegistryConfig registry;

    static {
        application = new ApplicationConfig();
        application.setName("jteach-cloud");
        registry = new RegistryConfig();
        registry.setAddress("zookeeper://218.0.51.85:2181");
    }

    public static JteachDubboService singletonJteachDubboService() {
        if (dubboService != null) {
            return dubboService;
        }
        dubboService = getJteachDubboService();
        return dubboService;
    }

    private static JteachDubboService getJteachDubboService() {
        ReferenceConfig<JteachDubboService> reference = new ReferenceConfig<JteachDubboService>();
        reference.setApplication(application);
        reference.setRegistry(registry);
        reference.setInterface(JteachDubboService.class);
        reference.setVersion("1.0.0");
        return reference.get();
    }

}
